package org.neframework.webtest.service;

import java.util.List;
import java.util.Map;

import com.tmsps.neframework.core.common.page.Page;
import com.tmsps.neframework.jpa.base.BaseService;
import com.tmsps.neframework.jpa.sql.param.NeParamList;

public class ArticleService extends BaseService {

	public static void main(String[] args) {
		ArticleService s = new ArticleService();
		System.err.println(s.selectArticleList());
	}

	public List<Map<String, Object>> selectArticleList() {
		String sql = "select * from t_s_article t where t.status=0 order by t.created desc";
		List<Map<String, Object>> list = jc.queryForList(sql);
		return list;
	}

	public List<Map<String, Object>> selectArticleList(String srh_name,
			String srh_cate, String bank_id, Map<String, String> sort_params,
			Page page) {
		if (sort_params.isEmpty()) {
			sort_params.put("t.created", "desc");
		}
		String sql = "select t.*,tb.name bank_name from t_s_article t "
				+ " left outer join t_s_bank tb on tb.status=0 and t.bank_id=tb.kid "
				+ " where t.status=0 and (t.title like ?) and (t.cate=?) and (t.bank_id=?) ";
		NeParamList param = NeParamList.makeParams();
		param.addLike(srh_name);
		param.add(srh_cate);
		param.add(bank_id);

		List<Map<String, Object>> list = jcn.queryForList(sql, param,
				sort_params, page);
		return list;
	}

}
